<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');


class Register extends Base_Controller
{
	
	
	
	public function __construct()
	{
		parent::__construct();
		$this->load->library('form_validation');
		$this->load->model('member_mdl','member');
		$this->load->library('authcode');
	}
	
	public function index()
	{
		$this->_validation_form();
		
		if($this->form_validation->run() == false)
		{
			$this->load->view('register');
		}
		else
		{
			echo $this->member->add_member(
				array(
					'tbnikename' => $this->input->post('tbnikename'),
					'tbpassword' => $this->common->do_hash($this->input->post('tbpassword')),
					'qq' => $this->input->post('qq'),
					'tbemail' => $this->input->post('tbemail'),
					'tbidcard' => $this->input->post('tbidcard'),
					'tbidcarkpic' => $this->input->post('tbidcarkpic'),
					'tbcompany' => $this->input->post('tbcompany'),
					'tbcompanypic' => $this->input->post('tbcompanypic'),
					'tbtype' => $this->input->post('tbtype'),
				)
				
			);
		}
		
	}

	/**
	 * 
	 * 检查用户名是否存在 ...
	 */
	
	function checkusername()
	{
		$tbnikename = $this->input->post('tbnikename');
		echo $this->member->checkusername($tbnikename);
		
	}
	
	
	public function _validation_form()
	{
		$this->form_validation->set_rules('tbnikename','tbnikename','required');
		$this->form_validation->set_rules('tbpassword','tbpassword','required');
		$this->form_validation->set_rules('repassword','repassword','required');
		$this->form_validation->set_rules('qq','tbnikename','required');
		$this->form_validation->set_rules('tbemail','tbemail','required');
		//$this->form_validation->set_rules('tbidcard','tbidcard','required');
		//$this->form_validation->set_rules('tbidcarkpic','tbnikename','required');
		//$this->form_validation->set_rules('tbcompany','tbnikename','required');
		//$this->form_validation->set_rules('tbtype','tbnikename','required');
	}
	
	private function _validation_form_person()
	{
		$this->form_validation->set_rules('tbnikename','tbnikename','trim|required|min_length[5]|max_length[12]|xss_clean');
		$this->form_validation->set_rules('tbpassword','tbpassword','required');
		$this->form_validation->set_rules('repassword','repassword','required|matches[tbpassword]');
		$this->form_validation->set_rules('qq','tbnikename','required');
		$this->form_validation->set_rules('tbemail','tbemail','required|valid_email');
		$this->form_validation->set_rules('tbcompany','tbnikename','required');

	}
}